/*
 * 2005-11-16 lxm 创建。 
 */
package com.hd123.rumba.sql;

import java.io.Serializable;
import java.util.List;

import net.sf.hibernate.HibernateException;

import com.hd123.rumba.exception.BusinessException;

/**
 * @author lxm
 * 
 * 相对于ResultPage的数据交换对象。<br>
 * 用于以分页的方式将结果集返回给WebService客户端。
 *
 */
public class DResultPage implements Serializable {
  
  private int page;
  private int pageSize;
  private int elementCount;
  private int pageCount;
  
  public final void assignFrom(ResultPage rp) throws BusinessException, HibernateException {
    List list = rp.getContentList();
    assignFrom(list);
    this.page = rp.getPage();
    this.pageSize = rp.getPageSize();
    this.elementCount = rp.getElementCount();
    this.pageCount = rp.getPageCount();
  }
  
  public void assignFrom(List list) throws BusinessException, HibernateException {
    this.page = 1;
    this.pageSize = list.size();
    this.elementCount = list.size();
    this.pageCount = 1;
  }
  
  public int getElementCount() {
    return elementCount;
  }
  public void setElementCount(int elementCount) {
    this.elementCount = elementCount;
  }
  public int getPage() {
    return page;
  }
  public void setPage(int page) {
    this.page = page;
  }
  public int getPageCount() {
    return pageCount;
  }
  public void setPageCount(int pageCount) {
    this.pageCount = pageCount;
  }
  public int getPageSize() {
    return pageSize;
  }
  public void setPageSize(int pageSize) {
    this.pageSize = pageSize;
  }

}
